from flask import Flask
from flask_restful import reqparse, Resource, Api, inputs


app = Flask(__name__)
api = Api(app)


"""
描述参数应该在请求数据中出现的位置
# Look only in the POST body
parser.add_argument('name', type=int, location='form')

# Look only in the querystring
parser.add_argument('PageSize', type=int, location='args')

# From the request headers
parser.add_argument('User-Agent', location='headers')

# From http cookies
parser.add_argument('session_id', location='cookies')

# From json
parser.add_argument('user_id', location='json')

# From file uploads
parser.add_argument('picture', location='files')

也可指明多个位置
parser.add_argument('text', location=['headers', 'json'])
"""
class UserResource(Resource):
    def get(self):
        rp = reqparse.RequestParser()
        rp.add_argument('age', location='form')
        args = rp.parse_args()
        print(args)
        return {"age":11}


api.add_resource(UserResource, '/user')


if __name__ == '__main__':
    app.run(debug=True)


